const cookie = {
    setItem(key, value, ops={}){
        let p = "";
        if(ops.path){
            p = ";path=" + ops.path;
        }
        let d = "";
        if(ops.expires){
            const date = new Date();
            date.setDate( date.getDate() + ops.expires );
            d = ";expires=" + date;
        }
        document.cookie = `${key}=${value}${p}${d}`;
    },
    removeItem(key, ops={}){
        ops.expires = -1;
        this.setItem(key, "", ops);
    },
    getItem(key){
        const arr = document.cookie.split("; ");
        for(let i=0;i<arr.length;i++){
            const a = arr[i].split("=");
            if(a[0] === key){
                return a[1];
            }
        }
        return null;
    }
}